package com.bw.controller;

import com.bw.entity.Bing;
import com.bw.entity.Zxt;
import com.bw.mapper.ZxtMapper;
import org.spring.kun.common.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class EchartsController {

    @Autowired
    ZxtMapper zxtMapper;

    @RequestMapping("/tu.do")
    public String tu(){

        return "tu";
    }

    @RequestMapping("/zxt.do")
    @ResponseBody // 把返回值 序列化为json格式
    public List<Zxt> zxt(Integer group){

      List<Zxt> list =  zxtMapper.zxt(group);
        return list;
    }

    @RequestMapping("/bing.do")
    @ResponseBody // 把返回值 序列化为json格式
    public List<Bing> bing(){

      List<Bing> list =  zxtMapper.bing();
        return list;
    }

    @RequestMapping("/excel.do")
    public void excel(Integer group,HttpServletResponse response){

        List<Zxt> list =  zxtMapper.zxt(group);

        ExcelUtils.exportExcel(list,"学生数量导出","sheet111",response);
    }
}
